<?php 
class AppError {
    public static function handleError($code, $description, $file = null, $line = null, $context = null) {

        
        if(Configure::read('debug')>0)t($description);
		App::uses('Error', 'Model');
		App::uses('CakeRequest', 'Network');
        $errordata = new Error();
        $request = new CakeRequest(null,false);
		$data=array(
			'host'=>$request->host(),
			'type'=>'error',
			'code'=>$code,
			'message'=>$description,
			'method'=>$_SERVER['REQUEST_METHOD'],
			'referer'=>$request->referer(),
			'here'=>$request->here(),
			'clientIp'=>$request->clientIp(),
			'input'=>$request->input(),
			'HTTP_USER_AGENT'=>$_SERVER['HTTP_USER_AGENT'],
			'HTTP_ACCEPT'=>$_SERVER['HTTP_ACCEPT'],
			'HTTP_COOKIE'=>$_SERVER['HTTP_COOKIE'],
			'CONTENT_TYPE'=>isset($_SERVER['CONTENT_TYPE'])?$_SERVER['CONTENT_TYPE']:'',
			'CONTENT_LENGTH'=>isset($_SERVER['CONTENT_LENGTH'])?$_SERVER['CONTENT_LENGTH']:0,
		);
		
		$errordata->save($data);
		
    }
}
?>
